﻿//////////////////////////////////
///htmlUpload上传组件
/////////////////////////////////
/*html部分
/*                    <div id="uploadElement">
                        <div class="item">
                            <input type="file" name="filedata"/><button type="button" onclick="myHtmlUpload.delEl(this)">del</button>
                        </div>
                    </div>
                    <button type="button" onclick="myHtmlUpload.addEl()">增加</button>
*/
var HtmlUpload = function () {
    this.init.apply(this, arguments);
}

HtmlUpload.prototype.init = function (elsId) {
    this.elObjs = new Array();
    this.elsEl = document.getElementById(elsId)
    this.elObjs[0] = document.getElementById(elsId).firstChild;
    this.elTemp = document.getElementById(elsId).firstChild.cloneNode();
    this.elChildTemp = document.getElementById(elsId).firstChild.innerHTML;

}
HtmlUpload.prototype.addEl = function () {
    var _tem = this.elTemp.cloneNode()
    _tem.innerHTML = this.elChildTemp;
    this.elObjs[this.elObjs.length] = this.elsEl.appendChild(_tem);
}
HtmlUpload.prototype.delEl = function (it) {
    var index = this.elObjs.length - 1;

    if (index == 0) { return; }
    for (index; index >= 0; index--) {
        //alert(it.parentNode.innerHTML + "\n---\n" + this.elObjs[index].innerHTML)
        if (it.parentNode == this.elObjs[index]) {


            // debugger;
            this.elObjs.splice(index, index + 1)
            it.parentNode.parentNode.removeChild(it.parentNode)

            return;
        }
    }
}
HtmlUpload.prototype.getElTemp = function () {
}
